//
//  CPYMVTableViewCell.m
//  TTMusic
//
//  Created by chenpengyu on 16/4/8.
//  Copyright © 2016年 cpy. All rights reserved.
//

#import "CPYMVTableViewCell.h"

@implementation CPYMVTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.titleLabel = [[TTMusicBaseLabel alloc] init];
        _titleLabel.font = [UIFont boldSystemFontOfSize:18];
        _titleLabel.textColor = [UIColor blackColor];
        [self.contentView addSubview:_titleLabel];
        
        self.bigImageView = [[UIImageView alloc] init];
        _bigImageView.userInteractionEnabled = YES;
        [self.contentView addSubview:_bigImageView];
        
        self.playButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [_playButton setImage:[[UIImage imageNamed:@"播放"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ] forState:UIControlStateNormal];
        [_playButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.bigImageView addSubview:_playButton];
        
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    _bigImageView.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height - 65);
    
    _titleLabel.frame = CGRectMake(0, self.contentView.bounds.size.height - 55, self.contentView.bounds.size.width, 30);
    
    [_playButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(_bigImageView.mas_centerX);
        make.centerY.mas_equalTo(_bigImageView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(30, 30));
        
    }];
    
    
}

- (void)buttonAction:(UIButton *)sender {
    [self.delegate sendIndexthRow:self.num WithUrl:_urlModel.url];
    
    
}

- (void)setMvModel:(CPYMVModel *)mvModel {
    _mvModel = mvModel;
    
    _titleLabel.text = mvModel.desc;
    [_bigImageView sd_setImageWithURL:[NSURL URLWithString:mvModel.bigPicUrl]];
}

- (void)setUrlModel:(MVUrlModel *)urlModel {
    _urlModel = urlModel;
}

- (void)setShareModel:(CPYMVModel *)shareModel {
    _shareModel = shareModel;
    
    _titleLabel.text = shareModel.desc;
    [_bigImageView sd_setImageWithURL:[NSURL URLWithString:shareModel.bigPicUrl]];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
